//
//  ByCellScroeStoreDetailVipDay.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/11/8.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByCellScroeStoreDetailVipDay.h"

@implementation ByCellScroeStoreDetailVipDay

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)setupUI {
    
    [self.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    
    UIView *bgView = [UIView new];
    bgView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.top.equalTo(@0);
        make.right.equalTo(@-10);
    }];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.backgroundColor = BY_RED_COLOR;
    titleLabel.text = @"会员日";
    titleLabel.font = FONT(18);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.textColor = [UIColor whiteColor];
    [bgView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(@0);
        make.height.equalTo(@40);
    }];
    
    UIView *lastView;
    for (int i = 0; i < _vipContents.count; i ++) {
        
        UILabel *label = [[UILabel alloc] init];
        label.numberOfLines = 0;
        label.text = _vipContents[i];
        label.font = FONT(14);
        label.textAlignment = NSTextAlignmentLeft;
        label.textColor = [UIColor grayColor];
        [bgView addSubview:label];
        
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@10);
            make.right.equalTo(@-10);
            if (i == 0) {
                make.top.equalTo(titleLabel.mas_bottom).offset(10);
            } else {
                make.top.equalTo(lastView.mas_bottom).offset(5);
            }
        }];
        
        
        lastView = label;
    }
   
    [lastView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(bgView).offset(-10);
    }];
    
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView);
    }];
}

- (void)setVipContents:(NSArray *)vipContents {
    
    _vipContents = vipContents;
    
    [self setupUI];
}

@end
